<template>
  <div>
    <div>
      <input type="text" v-model="name" />
      <button @click="search">搜索</button>
    </div>
    <div v-for="(item, index) in arrData" :key="item.name">
      {{ item.name }}
    </div>
  </div>
</template>
<script setup>
import request from "../../utils/request.js";
import { ref } from "vue";
import { getMenuList } from "../../services/menu.js";
const arrData = ref([]);
const name = ref("");
// const axiosInstance = axios.create({
//   baseURL: "http://study.zmyfrank.com",
//   timeout: 10000,
// });
const search = () => {
  const newArr = arrData.value.filter((item) => item.name.includes(name.value));
  arrData.value = newArr;
};

const getData = async () => {
  const res = await getMenuList();
  arrData.value = res.data.data;
  console.log(res);
};
async function getData2() {}
// getMenuList().then((res) => (arrData.value = res.data.data));
getData();
</script>
<style></style>
